<%@ page language="java" pageEncoding="UTF-8"%>
<%@ include file="/base.jsp"%>
<%@ include file="/module/taglibs.jsp"%>
<%@ include file="/module/nocache.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<title>科研信息</title>
<%@ include file="/module/js.jsp"%>
</head>
<body>
	<form action="#" name="Form" id="Form" method="post">
		<input type="hidden" name="idList" id="idList"/>
        <input type="hidden" name="type" id="type" value="${type}"/>
		<%@ include file="/module/orderField.jsp"%>
		<table cellpadding="1" cellspacing="1" border="0">
		<c:if test="${_login_user_type==2}">
			<tr>
			    <td><input type="button" id="btnQuery" value="查询"
					class="inputButton" /></td>
				<td>
				 <kl:permission permisstionList="${permisstionList}"
                    currentUser="${_login_console_user}"
                    currentCatalogId="<%=CatalogUtils.getCatalogId(\"JKY_JKS_KYXX\")%>" key="add">
				<input type="button" id="btnAdd" value="添 加"
					class="inputButton" />
				</kl:permission>
				</td>
				<td>
				 <kl:permission permisstionList="${permisstionList}"
                    currentUser="${_login_console_user}"
                    currentCatalogId="<%=CatalogUtils.getCatalogId(\"JKY_JKS_KYXX\")%>" key="delete"> 
				<input type="button" id="btnDelete" value="删 除"
					 class="inputButton"/>
				</kl:permission>
				</td>
				<td><input type="button" id="btnExport" value="导出"
				 class="inputButton"/></td>			 
			</tr>
		</c:if>	
		</table>
		 <table cellpadding="1" cellspacing="1" style="width:70%;">
		<tr>
	        <td>类别：</td>
			<td> <select id="xxlb" name="xxlb" class="selectList2">
						<option value="">全部</option>
						<option value="1">通知公告</option>
						<option value="2">文件传阅</option>
				</select>
			</td>
			<td>标题：</td>
			<td><input type="text" name="subject" id="subject" value=""  autocomplete="off" class="inputText2" /></td>
	        <td>来源：</td>
			<td><input type="text" name="xxly" id="xxly" value=""  autocomplete="off" class="inputText2" /></td>
		</tr>
		<tr>
				<td>创建人：</td>
				<td><input type="text" name="creatorName" id="creatorName"  value="" autocomplete="off" class="inputText2" /></td>
				<td>创建日期：</td>
				<td colspan="3">
				   <input type="text" name="begintime" id="begintime"   autocomplete="off" 
					   class="Wdate inputText2" value=""
					   onFocus="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss'})"/>&nbsp;到
				   <input type="text" name="endtime" id="endtime"   autocomplete="off" 
				   class="Wdate inputText2" value=""
					   onFocus="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss'})"/>
				</td>
			</tr>
		</table>
     	<table id="dg"  style="width:100%;"
			data-options="pagination:true,collapsible:true,url:'${basePath}/scientificNotice/list?type=${type}',method:'post',remoteSort:true">
			<thead>
				<tr>
					<th data-options="field:'xxid',checkbox:true,width:80,align:'center'"></th>
					<th data-options="field:'subject',nowrap:true,width:200,align:'center',sortable:true,formatter:formater">标题</th>
					<th data-options="field:'xxlb',nowrap:true,width:300,align:'center',sortable:true,formatter:xxlb">类别</th>
					<th data-options="field:'xxly',nowrap:true,width:150,align:'center',sortable:true">来源</th>
					<th data-options="field:'fbdw',nowrap:true,width:200,align:'center',sortable:true">发表单位</th>
					<th data-options="field:'fbrq',nowrap:true,width:200,align:'center',sortable:true,formatter:formatDate">发表日期</th>
				</tr>
			</thead>
		</table>
	</form>
	<script type="text/javascript">
	 function formater(value, row, index) {
			return "<a href='${basePath}/scientificNotice/view?xxid=" + row.xxid + "'>"+ row.subject + "</a>";
	}
	 //格式化部门名称
	 function xxlb(val,row,index){
		 if(row.xxlb == '1') {
			 return "通知公告";	 
		 }
		 if(row.xxlb == '2') {
			 return "文件传阅";	 
		 }
		 return  				    
	} 
	 
		$(document).ready(
			function() {

			$('#dg').datagrid({
			   rowStyler: function(index,row){
			   },
			   onLoadSuccess: function(data){//加载完毕后获取所有的checkbox遍历
	           		if (data.rows.length > 0) {
					}
				},
			});
			//查询
			$('#btnQuery').click(function(){
				$('#dg').datagrid('load',{
					xxlb : $('#xxlb').val(),
					subject : $('#subject').val(),
					xxly : $('#xxly').val(),
					xxlb : $('#xxlb').val(),
					creatorName: $('#creatorName').val(),
                    begintime: $('#begintime').val(),
                    endtime: $('#endtime').val(),
                    type : $('#type').valid()
				});
			});
	 		$('#easyui-ck').click(function() {
				var data = $("#dg").datagrid("getSelections");
				for (var i = 0; i < data.length; i++) {
            	}
			});
			$('#btnAdd').click(function() {
				window.location.href = "${basePath}/scientificNotice/addInInt";
			});
			$('#btnDelete').click(function() {
			   $("#idList").val("");
				var count = 0;
				var idList = new Array();
				var sels = $("#dg").datagrid("getSelections");
				for(var i in sels){
					idList.push(sels[i].xxid);
					count++;
				}

				if (count == 0) {
					layer.alert("您至少选择一条删除记录信息", {icon: 3});
					return false;
				}else{
					  layer.confirm("您是否删除当前选中数据信息", {icon: 3, title:'提示',skin:'layer-ext-moon'}, function(index){
							$("#idList").val(idList);
							document.Form.action = "${basePath}/scientificNotice/delete";
							document.Form.submit();
					  },function(index){
							layer.close(index);
					  });
				}
			});
			// 导出
			$('#btnExport').on('click', function(){
				   layer.confirm("您确定要导出吗?", function(index){
					   //var rows = $("#dg").datagrid("getRows"); {icon: 3, title:'提示',skin:'layer-ext-moon'},
					  // var bodyData = JSON.stringify(rows);  //转成json字符串
					   // $("#bodyData").val(JSON.stringify(rows));
				    document.Form.action = "${basePath}/scientificNotice/export_scientificNotice";
					document.Form.submit();
					layer.close(index);
				   });
		});
		});
		if("${msg}"!=""){
		   layer.alert("${msg}", {icon: 6});
		}
	</script>
</body>
</html>
